<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>Should see the "bar" and "baz" lines centered in their own boxes. The "foo"
line should not be centered.</p>
<div id="sample" contenteditable>foo<div>bar<br>baz</div></div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');

    selection.collapse(sample.childNodes[1].firstChild, 0);
    selection.extend(sample.childNodes[1].lastChild, 1);
    document.execCommand('justifyCenter');

    assert_equals(sample.innerHTML, 'foo<div><div style="text-align: center;">bar</div><div style="text-align: center;">baz</div></div>', 'innerHTML');
    assert_false(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, sample.childNodes[1].firstChild.firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, sample.childNodes[1].lastChild.firstChild, 'focusNode');
    assert_equals(selection.focusOffset, 1, 'focusOffset');
});
</script>
